home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / timeline / mute.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  10.4 KB  |  276 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/TimeLine/RCS/mute.c,v 1.11 91/10/05 18:32:11 chua Exp Locker: drapeau $ */
  25. /* $Log:    mute.c,v $
  26.  * Revision 1.11  91/10/05  18:32:11  chua
  27.  * Change the name of UnmuteAppHandler to RemoveMuteAppHandler.
  28.  * 
  29.  * Revision 1.0  91/09/30  16:59:03  chua
  30.  * Update to version 1.0
  31.  * 
  32.  * Revision 0.66  91/09/26  18:01:49  chua
  33.  * Added two new functions, MuteAppHandler and UnmuteAppHandler.  These have the
  34.  * same function as the mute choice item in the edit info list.
  35.  * 
  36.  * Revision 0.65  91/09/25  13:51:08  chua
  37.  * Changed the instrument field, instInfo, to editInfo.
  38.  * Changed InstrumentInfo to EditInfo.
  39.  * 
  40.  * Revision 0.64  91/09/20  11:38:55  chua
  41.  * Correct an error in CheckOpenApp which causes the function to always
  42.  * return Error.
  43.  * 
  44.  * Revision 0.63  91/09/19  17:28:56  chua
  45.  * Make sure that variables are initialized properly.  Change formatting slightly,
  46.  * so that (if, for, while) statements with only one statement in them will not have
  47.  * braces.
  48.  * 
  49.  * Revision 0.62  91/09/04  15:10:32  chua
  50.  * Replaced the calls to notice_prompt with a call to AlertMessage.
  51.  * 
  52.  * Revision 0.61  91/08/16  17:00:55  chua
  53.  * In the CheckAppOpen procedure, do a DestroySender if the NewSender call is 
  54.  * successful.  This is to avoid having too many senders around, which will cause
  55.  * errors.
  56.  * 
  57.  * Revision 0.60  91/08/08  15:13:49  chua
  58.  * In CheckAppOpen, if the app is not alive anymore, make it permanently muted,
  59.  * and update its hostname to "App not open".
  60.  * 
  61.  * Revision 0.59  91/08/08  14:26:06  chua
  62.  * Added a new function, CheckAppOpen, which will check if an application is still open.
  63.  * 
  64.  * Revision 0.58  91/07/17  10:27:22  chua
  65.  * In the InstrumentMute function, draw the mute symbol so that it is 'thicker' and
  66.  * looks nicer.
  67.  * 
  68.  * Revision 0.57  91/07/09  16:58:49  chua
  69.  * 
  70.  * 
  71.  * Revision 0.56  91/06/25  17:36:33  chua
  72.  * In the InstrumentMute routine,  draw the circle and slash in red color instead of in black.
  73.  * 
  74.  * Revision 0.55  91/06/04  17:37:20  chua
  75.  * Added the copyright comments in the beginning of the file.
  76.  * 
  77.  * Revision 0.54  91/06/03  11:11:57  chua
  78.  * Make changes to accomodate multiple documents.  This involves identifying
  79.  * which is the current active window, that is, the one where the last mouse
  80.  * click was done.
  81.  * 
  82.  * Revision 0.53  91/05/29  14:37:44  chua
  83.  * Delete the InstrumentMuteOff routine and replace the InstrumentMuteOn by InstrumentMute, which
  84.  * will check if it is necessary to draw the circle and slash (mute indicator) symbol over the
  85.  * application icon of the instrument.
  86.  * 
  87.  * Changes are also made to the InstrumentMuteChoice routine, so that it will call the
  88.  * InstrumentDrawIcon routine with the proper parameters, such as whether the icon should be raised
  89.  * or sunken.
  90.  * 
  91.  * Revision 0.52  91/05/28  12:12:33  chua
  92.  * *** empty log message ***
  93.  * 
  94.  * Revision 0.51  91/05/28  12:04:39  chua
  95.  * This file contains the panel choice notify procedure for the mute choice panel item in the instrument
  96.  * info pop-up window and also 2 functions to draw/clear the mute indicator that appears besides the
  97.  * application icons in the AppCanvas.
  98.  *  */
  99.  
  100. static char mutercsid[] = "$Header: /Source/Media/collab/TimeLine/RCS/mute.c,v 1.11 91/10/05 18:32:11 chua Exp Locker: drapeau $";
  101.  
  102. #include "main.h"
  103.  
  104. /*
  105.  * Notify callback function for `MuteChoice'.
  106.  * This function checks whether the user has turned the mute function on or off and calls the appropriate drawing routine to display or turn off the
  107.  * mute indicator besides the application icon for that instrument.
  108.  */
  109. int InstrumentMuteChoice(item, value, event)
  110.      Panel_item    item;
  111.      int        value;
  112.      Event        *event;
  113. {
  114.   Instrument *instrument;
  115.   int currentApp, type;
  116.   TimeLineFramePtr tlFrame;
  117.   EditInfo_EditInfoWindow_objects    *ip = (EditInfo_EditInfoWindow_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  118.   Window    owner = xv_get(ip->EditInfoWindow, XV_OWNER);
  119.   TimeLine_window_objects * tlip = (TimeLine_window_objects *) xv_get(owner, XV_KEY_DATA, INSTANCE);
  120.  
  121.   tlFrame = TimeLineWindow[xv_get(tlip->controls, PANEL_CLIENT_DATA)];
  122.   currentApp = (int) xv_get(ip->NoteInfoList, PANEL_CLIENT_DATA);
  123.   instrument = (Instrument*) FindInstrument(currentApp, tlFrame);   /* Find the instrument for this info pop-up window */
  124.   if (instrument == NULL) 
  125.     return;
  126.   type = Raised;  
  127.   if (currentApp == tlFrame->chosenApp)                    /* Determine if the current instrument is selected */
  128.     type = Sunken;
  129.   InstrumentDrawIcon(instrument, type, tlFrame);
  130. }
  131.  
  132. /*
  133.  * This function checks to see if the mute choice is on.  If so, it draws a circle and a forward slash across the application icon in red.
  134.  * Called by InstrumentMuteChoice (mute.c)
  135.  */
  136. void InstrumentMute(instrument, tlFrame)
  137.      Instrument *instrument;
  138.      TimeLineFramePtr tlFrame;
  139. {
  140.   if (xv_get(instrument->editInfo->MuteChoice, PANEL_VALUE))        /* Check if mute is on */
  141.   {
  142.     XSetForeground(tlFrame->dpyApp, tlFrame->gc, (long)tlFrame->pixelTable[Red]); /* Set the foreground color to black */
  143.     XSetBackground(tlFrame->dpyApp, tlFrame->gc, (long)tlFrame->pixelTable[Grey84]); /* Set the background color to light grey */
  144.     SetLineAttributes(tlFrame, 4);                    /* Increase the line width */
  145.     XDrawArc(tlFrame->dpyApp, tlFrame->xidApp, tlFrame->gc, IconXOffset + 3, instrument->cableStart - 30,
  146.          IconHeight - 6, IconHeight - 6, 0,0);
  147.     XDrawLine(tlFrame->dpyApp, tlFrame->xidApp, tlFrame->gc, IconXOffset + IconHeight - 9, 
  148.           instrument->cableStart - 18, IconXOffset + 9, 
  149.           instrument->cableStart + 18);
  150.     SetLineAttributes(tlFrame, 2);                    /* Reset the line width back to normal */
  151.   }
  152. }
  153.  
  154. /*
  155.  * This function prints out an error message when the user tries to play or insert a new note in an application that is currently
  156.  * not open.  If mode = 1, the operation is an insert, else if mode = 0, the operation is a play.  Otherwise, mode = 2.
  157.  */
  158. int CheckAppOpen(tlFrame, instrument, mode)
  159.      TimeLineFramePtr tlFrame;
  160.      Instrument *instrument;
  161.      int mode;
  162. {
  163.   Sender *sender;
  164.   char buf[100], buf1[100];
  165.   
  166.   if (xv_get(instrument->editInfo->MuteChoice, PANEL_VALUE) == 0 
  167.       || mode == 1)
  168.   {
  169.     if (mode == 1) 
  170.       sprintf (buf1, "You cannot insert a new note for this application.");
  171.     else if (mode == 0)
  172.       sprintf (buf1, "You cannot perform a play operation for this application.");
  173.     else 
  174.       sprintf (buf1, "");
  175.     sprintf (buf, "Sorry, the application %s is not open.", instrument->port->appName);
  176.     if (strcmp(instrument->port->hostName, "App not open") == 0)    /* Check if the application has never been opened before. */
  177.     {
  178.       AlertMessage(tlFrame, buf, buf1, NULL);
  179.       return Error;
  180.     }
  181.     sender = NewSender(instrument->port);
  182.     if (sender == NULL)                            /* Check if the application (that was opened previously) is still open. */
  183.     {
  184.       xv_set(instrument->editInfo->MuteChoice, PANEL_VALUE, 1, NULL);
  185.       xv_set(instrument->editInfo->MuteChoice, PANEL_INACTIVE, TRUE, NULL);
  186.       strcpy(instrument->port->hostName, "App not open");
  187.       xv_set(instrument->editInfo->HostnameText,            /* Set the hostname on the pop-up window */
  188.          PANEL_LABEL_STRING, instrument->port->hostName, NULL);
  189.       AlertMessage(tlFrame, buf, buf1, NULL);
  190.       AppCanvasRepaintHandler(tlFrame->TimeLine_window->AppCanvas, tlFrame->paintWinApp, /* Repaint the apps canvas so that the icon shows muted */
  191.                   tlFrame->dpyApp, tlFrame->xidApp, NULL);
  192.       return Error;
  193.     }
  194.     else 
  195.       DestroySender(sender);
  196.   }
  197.   return OK;
  198. }
  199.  
  200. /*
  201.  * Menu handler for `AppMenu (Mute application)'.
  202.  */
  203. Menu_item MuteAppHandler(item, op)
  204.      Menu_item    item;
  205.      Menu_generate    op;
  206. {
  207.   Instrument *instrument;
  208.   TimeLineFramePtr tlFrame;
  209.   TimeLine_window_objects    *ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  210.  
  211.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  212.   switch (op) 
  213.   {
  214.    case MENU_DISPLAY:
  215.     break;
  216.    case MENU_DISPLAY_DONE:
  217.     break;
  218.    case MENU_NOTIFY:
  219.     if (tlFrame->chosenApp >= 0) 
  220.     {
  221.       instrument = (Instrument *) FindInstrument(tlFrame->chosenApp, tlFrame);
  222.       if (instrument == NULL)
  223.     return item;
  224.       if (xv_get(instrument->editInfo->MuteChoice, PANEL_VALUE) == 0 &&
  225.       strcmp(instrument->port->hostName, "App not open") != 0)
  226.       {
  227.     xv_set(instrument->editInfo->MuteChoice, PANEL_VALUE, 1, NULL);
  228.     InstrumentDrawIcon(instrument, Sunken, tlFrame);
  229.       }
  230.     }
  231.     break;
  232.    case MENU_NOTIFY_DONE:
  233.     break;
  234.   }
  235.   return item;
  236. }
  237.  
  238. /*
  239.  * Menu handler for `AppMenu (Remove mute from application)'.
  240.  */
  241. Menu_item RemoveMuteAppHandler(item, op)
  242.      Menu_item    item;
  243.      Menu_generate    op;
  244. {
  245.   Instrument *instrument;
  246.   TimeLineFramePtr tlFrame;
  247.   TimeLine_window_objects    *ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  248.  
  249.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  250.   switch (op) 
  251.   {
  252.    case MENU_DISPLAY:
  253.     break;
  254.    case MENU_DISPLAY_DONE:
  255.     break;
  256.    case MENU_NOTIFY:
  257.     if (tlFrame->chosenApp >= 0) 
  258.     {
  259.       instrument = (Instrument *) FindInstrument(tlFrame->chosenApp, tlFrame);
  260.       if (instrument == NULL)
  261.     return item;
  262.       if (xv_get(instrument->editInfo->MuteChoice, PANEL_VALUE) == 1 && 
  263.       strcmp(instrument->port->hostName, "App not open") != 0)
  264.       {
  265.     xv_set(instrument->editInfo->MuteChoice, PANEL_VALUE, 0, NULL);
  266.     InstrumentDrawIcon(instrument, Sunken, tlFrame);
  267.       }
  268.     }
  269.     break;
  270.    case MENU_NOTIFY_DONE:
  271.     break;
  272.   }
  273.   return item;
  274. }
  275.  
  276.